package com.nulldev.util.net.packets.npcrypt;

import com.nulldev.util.crypto.encryptAPI.rsa.RSA;
import com.nulldev.util.java.DataSet;
import com.nulldev.util.other.ByteUtils;

public class NPCrypt {
	
	/**
	 * Generates a key pair
	 * @returns DataSet of Base 64 keys <br>
	 * - Key 1: Public Key [Encryption] <br>
	 * - Key 2: Private Key [Decryption]
	 */
	public static DataSet<String, String> createKeySet() {
		final DataSet<byte[], byte[]> key = RSA.generateKey();
		return new DataSet<String, String>(ByteUtils.toBase64(key.getA()), ByteUtils.toBase64(key.getB()));
	}
	
	/**
	 * Generates a key pair
	 * @returns DataSet of Base 64 keys <br>
	 * - Key 1: Public Key [Encryption] <br>
	 * - Key 2: Private Key [Decryption]
	 */
	public static DataSet<String, String> createKeySet4096() {
		final DataSet<byte[], byte[]> key = RSA.generateKey(4096);
		return new DataSet<String, String>(ByteUtils.toBase64(key.getA()), ByteUtils.toBase64(key.getB()));
	}
}
